package com.tjh.spring5.testdemo;

import com.tjh.spring5.aopanno.User;
import com.tjh.spring5.aopxml.Book;
import com.tjh.spring5.config.ConfigAop;
import com.tjh.spring5.service.UserService3;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Create by koala on 2021-02-17
 */
public class TestAopDay26 {

    //day26、day27、day28
    @Test
    public void testAopAnno() {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("beanday26.xml");
        User user = context.getBean("user", User.class);
        user.add();
    }

    //day29
    @Test
    public void testAopXml() {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("beanday29.xml");
        Book book = context.getBean("book", Book.class);
        book.buy();
    }

    //day30
    @Test
    public void testAopXml1() {
        ApplicationContext context
                = new AnnotationConfigApplicationContext(ConfigAop.class);
        UserService3 userService = context.getBean("userService3", UserService3.class);
        System.out.println(userService);
        userService.add();
    }

}
